package dryven.util.json.dryvenjson.encoders;

import java.io.IOException;

import dryven.model.di.LocalThreadStorage;
import dryven.util.json.JsonEncoder;
import dryven.util.json.dryvenjson.FieldPolicy;
import dryven.util.json.dryvenjson.JSONCompositeEncoder;
import dryven.util.json.dryvenjson.JSONTypeEncoder;

public class NumberEncoder implements JSONTypeEncoder {

	@Override
	public void encodeValue(Object value, JSONCompositeEncoder e, FieldPolicy p, LocalThreadStorage diStorage, Appendable dest) throws IOException {
		dest.append(value.toString());
	}

	@Override
	public boolean isApplicableForType(Class<?> type) {
		return type.equals(int.class) || 
			type.equals(byte.class) || 
			type.equals(short.class) || 
			type.equals(long.class) || 
			type.equals(double.class) || 
			type.equals(float.class) ||
			type.equals(Integer.class) || 
			type.equals(Byte.class) || 
			type.equals(Short.class) || 
			type.equals(Long.class) || 
			type.equals(Double.class) || 
			type.equals(Float.class);
	}

}
